# Contributor: Stuart Cardall <developer@it-offshore.co.uk>
# Maintainer: Stuart Cardall <developer@it-offshore.co.uk>
pkgname=py3-lz4
pkgver=3.1.10
_pkgname=${pkgname#py3-}
pkgrel=0
pkgdesc="LZ4 Bindings for Python"
url="https://pypi.python.org/pypi/lz4"
arch="all"
license="BSD-3-Clause"
makedepends="python3-dev py3-setuptools lz4-dev linux-headers py3-pkgconfig py3-setuptools_scm
	pkgconf"
checkdepends="py3-pytest py3-psutil py3-pytest-cov py3-coverage py3-pytest-runner"

# FIXME: check fails on s390x
if [ "$CARCH" = "s390x" ]; then
	options="!check"
fi

subpackages="$pkgname-tests:_tests:noarch"
source="https://files.pythonhosted.org/packages/source/${_pkgname:0:1}/$_pkgname/$_pkgname-$pkgver.tar.gz
	"
builddir="$srcdir/$_pkgname-$pkgver"

replaces="py-lz4" # Backwards compatibility
provides="py-lz4=$pkgver-r$pkgrel" # Backwards compatibility

prepare() {
	default_prepare
	rm lz4libs/lz4*.[ch]
}

build() {
	python3 setup.py build
}

check() {
	python3 setup.py test
}

package() {
	python3 setup.py install --prefix=/usr --root="$pkgdir"
}

_tests() {
	pkgdesc="$pkgdesc (tests)"

	mkdir -p "$subpkgdir"/usr/share/$pkgname
	mv "$builddir"/tests "$subpkgdir"/usr/share/$pkgname
}

sha512sums="
61983e77fa445f59503ccf8ed5fe0605d79754cdeb166e16a7093a856b23369634db7d105d57b3829e680dad0a3728adec9d18dccd92c994347b74c5af95580e  lz4-3.1.10.tar.gz
"
